subway_df = read_csv("./Data/NYC_Transit_Subway_Entrance_And_Exit_Data.csv") %>%
janitor::clean_names()
# Clean subway data
subway_df = subway_df %>%
select( -ada_notes, -staff_hours, -north_south_street, -east_west_street, -corner) %>%
mutate(
entrance_type = factor(
entrance_type,
levels = c("Stair", "Easement", "Door", "Walkway", "Escalator", "Ramp", "Elevator"),
ordered = TRUE
)
) %>%
mutate(
staffing = factor(
staffing,
levels = c("NONE", "Spc Ev", "PART", "FULL"),
ordered = TRUE
)
)
# Importing NYC map
nyc_map = st_read(here::here('NYC', 'nyc.shp'), quiet = TRUE)
nycmap = st_transform(nyc_map, crs = 4326)
subway_df %>%
ggplot() +
geom_sf(
data = nyc_map, fill = NA
) +
geom_point(
aes(x = station_longitude, y = station_latitude, color = ada),
size = 2.5, alpha = 0.5) +
coord_sf() +
theme_void(base_size = 10) +
theme(legend.position = 'bottom') +
guides(color = guide_legend(
title.position = "top",
override.aes = list(size = 3))) +
scale_color_manual(values = c("FALSE" = "aquamarine3", "TRUE" = "slateblue3")) +
labs(color = "ADA Compliance")
subway_df %>%
group_by(ada) %>%
count(ada) %>%
plot_ly (x = ~ada,
y = ~n,
color = ~ada,
type = "bar") %>%
layout(
xaxis = list(title = "Ada Complaince"),
yaxis = list(title = "Number of Stations")
)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
subway_df %>%
group_by(entrance_type) %>%
count(entrance_type) %>%
ungroup() %>%
mutate(entrance_type = fct_reorder(entrance_type, n, .desc = TRUE)) %>%
plot_ly (x = ~entrance_type, y = ~n,
color = ~entrance_type,
type = "bar", colors = "viridis") %>%
layout(
xaxis = list(title = "Entrance Type"),
yaxis = list(title = "Number of Stations")
)
subway_df %>%
ggplot() +
geom_sf(
data = nyc_map, fill = NA
) +
geom_point(
aes(x = station_longitude, y = station_latitude, color = free_crossover),
size = 2.5, alpha = 0.5) +
coord_sf() +
theme_void(base_size = 10) +
theme(legend.position = 'bottom') +
guides(color = guide_legend(
title.position = "top",
override.aes = list(size = 3))) +
labs(color = "Free Crossover")
subway_df %>%
group_by(free_crossover) %>%
count(free_crossover) %>%
plot_ly (x = ~free_crossover,
y = ~n,
color = ~free_crossover,
type = "bar") %>%
layout(
xaxis = list(title = "Free Crossover"),
yaxis = list(title = "Number of Stations")
)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
subway_df %>%
group_by(staffing) %>%
count(staffing) %>%
ungroup() %>%
mutate(staffing = fct_reorder(staffing, n, .desc = TRUE)) %>%
plot_ly(
x = ~staffing,
y = ~n,
color = ~staffing,
type = "bar",
colors = "viridis"
) %>%
layout(
xaxis = list(title = "Staffing"),
yaxis = list(title = "Number of Stations")
)